package net.lcheng.service.impl;

import net.lcheng.dao.WxShopCategoryMapper;
import net.lcheng.model.WxShopCategory;
import net.lcheng.model.WxShopCategoryExample;
import net.lcheng.service.WxShopCategoryService;
import net.lcheng.vo.WxshopCategoryExtention;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zwr on 2016/7/5 0005.
 */
@Service
public class WxShopCategoryServiceImpl implements WxShopCategoryService {
    @Resource
    private WxShopCategoryMapper mapper;

    @Override
    public List<WxShopCategory> getWxShopCategoryByShopId(Integer shopId) {
        WxShopCategoryExample example = new WxShopCategoryExample();
        example.or().andShopIdEqualTo(shopId).andStatusEqualTo(1);
        return mapper.selectByExample(example);
    }

    @Override
    public int addCategory(WxShopCategory wxShopCategory) {
        return mapper.insertSelective(wxShopCategory);
    }

    @Override
    public WxShopCategory getWxShopCategoryByCategoryId(String categoryId) {
        return mapper.selectByPrimaryKey(categoryId);
    }

    @Override
    public int modifyCategory(WxShopCategory wxShopCategory) {
        return mapper.updateByPrimaryKeySelective(wxShopCategory);
    }

    @Override
    public int modifyStatus(WxShopCategory wxShopCategory) {
        return mapper.updateByPrimaryKeySelective(wxShopCategory);
    }

    @Override
    public int deleteShopCategoryByPrimaryKey(String key) {
        return mapper.deleteByPrimaryKey(key);
    }

    @Override
    public List<WxshopCategoryExtention> getShopCategoryAndProductNumByShopId(int shopId) {
        return mapper.selectShopCategoryAndProductNumByShopId(shopId);
    }
}
